package test15;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * 1.ArrayList<Integer> list = new ArrayList<Integer>();
 这个泛型为Integer的ArrayList中存放一个String类型的对象
 */
public class Test1 {
    public static void main(String[] args) throws NoSuchFieldException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(22);
        list.add(33);


        Class clazz = list.getClass();
        Method add = clazz.getDeclaredMethod("add", Object.class);
        add.setAccessible(true);
        add.invoke(list,"eeee");


        System.out.println(list);
    }
}
